package MyThread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: AliceMana
 * Date: 2022-12-31
 * Time: 15:51
 */
public class ThreadDemo11 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 1000_0000; i++) {
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        // 启动之前, 获取t的状态, 就是NEW状态
        System.out.println("start之前: " + t.getState());

        t.start();
        for (int i = 0; i < 100; i++) {
            System.out.println("t 执行中的状态: " + t.getState());
        }
        t.join();

        // 执行完毕之后, 就是TERMINATED状态
        System.out.println("t 结束之后: " + t.getState());
    }

}
